package com.dc.chat.controller;

import com.dc.chat.app.biz.FriendBiz;
import com.dc.chat.entity.to.ResponseBean;
import com.dc.chat.entity.to.friend.DeleteFriend;
import com.dc.chat.entity.to.friend.FriendListItem;
import com.dc.chat.entity.to.friend.SetFriendBackReq;
import com.dc.chat.interceptor.security.Security;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/friend")
public class FriendController {
    @Resource
    FriendBiz friendBiz;
    @Security
    @PostMapping("/getFriendList")
    public ResponseBean<List<FriendListItem>> getFriendList(){
        return friendBiz.getFriendList();
    }
    @Security
    @PostMapping("/deleteFriend")
    public ResponseBean deleteFriend(@Validated @RequestBody DeleteFriend req){
        return friendBiz.deleteFriend(req.getFriendId());
    }
    @Security
    @PostMapping("/setFriendBack")
    public ResponseBean setFriendBack(@RequestBody @Validated SetFriendBackReq req){
        return friendBiz.setFriendBack(req);
    }
    @Security
    @PostMapping("/setActiveUser")
        public void setActiveUser(@RequestParam("id") Integer id){
            friendBiz.setActiveUser(id);
        }
}
